﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Aribaccio;
using CommunityToolkit.Mvvm.ComponentModel;

namespace BDPAutodetect.Models
{
    public partial class MPowerPermission : ObservableModel
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// 角色实例
        /// </summary>
        [ObservableProperty]
        protected MRoleDto role;

        /// <summary>
        /// 权限实例
        /// </summary>
        [ObservableProperty]
        protected MPowerDto power;

        /// <summary>
        /// 权限许可（0 No，1 Yes）
        /// </summary>
        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(PermissionMode))]
        protected int permission;

        /// <summary>
        /// 权限许可（0 No，1 Yes）
        /// </summary>
        public ExecuteStatus PermissionMode => this.Permission.ToEnum<ExecuteStatus>();

        /// <summary>
        /// 构造函数
        /// </summary>
        public MPowerPermission()
        {
            this.Role = new MRoleDto();
            this.Power = new MPowerDto();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public MPowerPermission(int argID, MRoleDto argRole, MPowerDto argPower, int argPermission)
        {
            this.ID = argID;
            this.Role = argRole;
            this.Power = argPower;
            this.Permission = argPermission;
        }

        public TBasicRPRelation CloneTData()
        {
            return new TBasicRPRelation()
            {
                ID = this.ID,
                RoleID = this.Role.ID,
                PowerID = this.Power.ID,
                Permission = this.Permission
            };
        }
    }
}
